home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / i18n / README < prev    next >
Encoding:
Text File  |  1994-08-02  |  6.7 KB  |  196 lines

  1.  
  2.                 ~4Dgifts/toolbox/src/exampleCode/i18n README
  3.  
  4.  
  5.            This directory contains example source code dealing with 
  6.            internationalization and localization as well as draft 
  7.        copies of the IRIX Internationalization chapter (Primer.ps)
  8.        for what will eventually be the Internationalization chapter
  9.        of the "IRIX Systems Programming Guide" as well as a Nutshell
  10.        (Nutshell.ps) guide as an attempt to supply a high-level 
  11.        description of the issues involved in internationalizing 
  12.        software.
  13.        
  14.        To successfully run the programs in this directory, you 
  15.        need to be running an O.S level of 5.* or higher, and 
  16.        need to have Motif 1.2 running and X11 R5. 
  17.  
  18.            Some examples will also require installed images of 
  19.            intl.sw.  See below for more details.
  20.  
  21.  
  22.            See the Frequently Asked Questions i18n file located at
  23.            ~4Dgifts/toolbox/FAQs/netfaqs/i18n-faq.
  24.  
  25.  
  26.  
  27. xpg3_wchar : 
  28.  
  29.    this is a sample code which shows two things
  30.  
  31.    1) use of wide characters for string manipulation
  32.    2) XPG/3 way of doing message catalogs (the other 
  33.       interface of cataloging is MNLS).
  34.  
  35.    the sample code is supplied with Japanese and German 
  36.    catalogs under the directory jp and de respectively.
  37.  
  38.    to run the Japanese version : 
  39.  
  40.    setenv XMODIFIERS @im=_XWNMO
  41.    run xwnmo
  42.    run iwsh or exterm 
  43.  
  44.    setenv NLSPATH jp
  45.    setenv LANG ja_JP.EUC
  46.    xpg3_wchar  japanese_input_string
  47.  
  48.    and for German
  49.  
  50.    setenv NLSPATH de
  51.    setenv LANG de
  52.    xpg3_wchar  german_input_string
  53.  
  54.    do man catopen for full details on the location of catalogs.
  55.    do man gencat  for help on generating message catalogs.
  56.  
  57.    if the NLSPATH environment variable is not set, it
  58.    will run in the default english mode.
  59.  
  60.    the program takes the input string and outputs two strings
  61.    which are made of even and odd alphabets from the original
  62.    string (not useful in real life, but shows how to manipulate
  63.    wide character strings).
  64.  
  65. mnls_wchar : 
  66.  
  67.    this is similar to xpg3_wchar except that it uses mnls
  68.    way of cataloging.
  69.  
  70.    the sample code is supplied with Japanese and German 
  71.    catalogs under the directory jp and de respectively.
  72.  
  73.    you will have to move (or copy) the file mnls_wchar.cat from these
  74.    respective directories to 
  75.  
  76.    /usr/lib/locale/de/LC_MESSAGES for German
  77.    and to /usr/lib/locale/ja_JP.EUC/LC_MESSAGES for Japanese
  78.  
  79.    to run the Japanese version : 
  80.  
  81.    setenv LANG ja_JP.EUC
  82.    mnls_wchar  japanese_input_string
  83.  
  84.    and for German
  85.  
  86.    setenv LANG de
  87.    mnls_wchar  german_input_string
  88.  
  89.  
  90. =======================================================================
  91.  
  92. Message Catalogs for Internationalization :
  93. -------------------------------------------
  94.  
  95. Apart from the text which appears on the user interface 
  96. widgets, an internationalized application must display 
  97. other texts like prompts, error messages in the native 
  98. language. Message cataloging facility is commonly used for this 
  99. type of intertionalization of strings.
  100.  
  101. Message catalogs are compiled databases of strings. The application
  102. extracts all the strings from a locale dependent message catalog.
  103. Although these strings are commonly used for communication
  104. in the native language, they can be used for any purpose.
  105.  
  106. On Irix, there are two different interfaces to message catalogs:
  107. MNLS and XPG/3. MNLS is AT&T's Multi National Language Support and
  108. XPG/3 is the X/Open Portability Guide, Issue 3, by X/Open, Ltd.
  109. Developers working on base system utilities will probably be
  110. using MNLS, whereas developers working on independent projects will
  111. be using XPG/3. In order to maximize portability, developers are
  112. encouraged to use XPG/3 if given a choice.
  113. Catalog generation is exclusively the task of localizers. But the
  114. developer must know the contents of the catalog in order to specify
  115. the number of a message to be used in the application. So in order
  116. to inform the localizer which strings to translate and how they
  117. should create a catalog, the application developer should provide
  118. a master catalog for the developer's locale.
  119.  
  120. MNLS message catalogs
  121. ---------------------
  122.  
  123.     MNLS message catalogs are merely list of strings in a file, separated
  124. by new-lines. Strings are referenced by line number in the original 
  125. source file. Adding strings to an existing catalog should only be done
  126. at the end of the file. Otherwise, applications already using this catalog
  127. will end up accessing different strings. The three functions
  128. pfmt, gettxt, and printf are sufficient for most applications in
  129. this interface. fmtmsg() a comprehensive formatter is also available.
  130.  
  131. MNLS catalogs do not need to be specifically opened. The catalog can be
  132. set explicitly once, or it can be specified everytime a string is
  133. needed.
  134.  
  135. When a file of message strings is ready to be compiled, run mkmsgs()
  136. and save the file in /usr/lib/locale/<locale>/LC_MESSAGES
  137. (for example <locale> for german could be de).
  138.  
  139. following is an example German mnls message strings which needs to
  140. be compiled using mkmsgs
  141.  
  142. Benutzung: %s Zeichenkette\n
  143. Kein freier Speicher mehr\n
  144. Fehler beim Erzeugen eines 'wide characters'\n
  145. Hier ist die Ausgabe :
  146.  
  147. mnls_wchar is an example source which uses MNLS interface of catalog.
  148.  
  149. XPG/3 message catalogs 
  150. ----------------------
  151.  
  152.     XPG/3 message catalogs contains sets of numbered messages. The 
  153. three functions catopen, catgets, and catclose, provide a simple
  154. mechanism for retrieving numbered strings from a plain text file.
  155. This interface requires that a catalog be opened before it is read.
  156.  
  157. The XPG/3 catalogs are located using the environment variable NLSPATH.
  158. The man page on catopen() gives full details on the path.
  159.  
  160. After creating the file with message strings, you need to compile them
  161. into a binary form using gencat() and save the file in the location
  162. where catopen() can find it (NLSPATH mentioned above).
  163.  
  164. following is an example German xpg3 message strings which needs to
  165. be compiled using gencat
  166.  
  167. $set 1
  168. 1 Benutzung: %s Zeichenkette\n
  169. 2 Kein freier Speicher mehr\n
  170. 3 Fehler beim Erzeugen eines 'wide characters'\n
  171. 4 Hier ist die Ausgabe :
  172.  
  173. xpg3_wchar is an example source which uses XPG/3 interface of catalog.
  174.  
  175. Wide Characters
  176. ---------------
  177.  
  178. The example source also demonstrates another very useful concept
  179. in internationalized applications: the wide character.
  180. A wide character is a data object of type wchar_t, which holds the
  181. system's largest numerical code for a character. On Irix 5.* and
  182. beyond, the sizeof(wchar_t) is 4.
  183.  
  184. Since the strings made of wide characters have all the characters of
  185. the same size, the string can be treated as an array, and the application
  186. can simply index into the array in order to manipulate it.
  187.  
  188. Wide characters are not as space efficient as multibyte strings and
  189. applications which do not need to perform string editing may never
  190. use wchars.
  191.  
  192. -----------------
  193. Yusuf Attarwala
  194. SGI - Applications.
  195. x 3-3342
  196.